package cn.tongdun.atreus.common.log;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 * @author wangze
 * @date 2021-10-20 15:14.
 **/
@Configuration
@EnableScheduling
public class LogScheduleTask {

	private static final Logger logger = LoggerFactory.getLogger(LogScheduleTask.class);

	@Resource
	private LoggerUtil loggerUtil;

	//@Scheduled(cron = "0/5 * * * * ?")
	//或直接指定时间间隔，例如：5秒

	/**
	 * 定时更新数据日志
	 */
	@Scheduled(fixedRate = 1800000)
	private void updateRules() {
		logger.info("脱敏规则数据更新成功。。。。。");
		LoggerUtil.UPDATE_EXECUTE_RULES.clear();
		LoggerUtil.UPDATE_EXECUTE_RULES.addAll(loggerUtil.getRuleFromDb());
		LoggerUtil.IS_UPDATEING = true;
	}
}
